package com.tarena.lbs.basic.web.utils;

import com.tarena.lbs.common.passport.principle.UserPrinciple;

//系统通过工具类构造的 save方法存储数据 get方法取数据 remove 清空数据等等
public class UserPrincipleThreadLocal {
    private static ThreadLocal<UserPrinciple> THREADLOCAL=new ThreadLocal<>();

    //存储数据
    public static void save(UserPrinciple user){
        THREADLOCAL.set(user);
    }
    //获取数据
    public static UserPrinciple get(){
        return THREADLOCAL.get();
    }
    //清空数据 将当前线程的value删除
    public static void clear(){
        THREADLOCAL.remove();
    }

}
